@extends('admin.main')
@section('content')
    <div class="daohang">
        <ul>
            <li>
                <button type="button" class="am-btn am-btn-default am-radius am-btn-xs"> 自定义菜单</button>
            </li>
        </ul>
    </div>
    <div class="admin-biaogelist">
        <div class="listbiaoti am-cf">
            <ul class="am-icon-flag on">
                {{isset($data['name']) ? '编辑菜单' : '添加菜单'}}
            </ul>
            <dl>
            </dl>
        </div>
        <div class="am-popup-bd">
            <form class="am-form tjlanmu" method="post" action="{{isset($data) ? urlAdmin('wechatMenus','postEdit') : urlAdmin('wechatMenus','postCreate')}}">
                <div class="am-form-group  am-cf">
                    <div class="zuo">父级菜单：</div>
                    <div class="you">
                        <select name="pid" id="pid" style="width:150px;height:30px;font-size: 11px;" class="chosen-select" tabindex="7">
                            <option value="0">顶级菜单</option>
                            @if( isset($menus) && count($menus) > 0    )
                                @foreach($menus as $m)
                                    <option value="{{$m->id}}" @if(  isset($data) && ($m->id == $data->pid) ) selected @endif>{{$m->name}}</option>
                                @endforeach
                            @endif
                        </select>
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">菜单名称：</div>
                    <div class="you">
                        <input style="width:200px"  class="am-input-sm" name="name" type="text" value="{{isset($data['name']) ? $data['name'] : ''}}" placeholder="请输入菜单名称">
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">类型：</div>
                    <div class="you" style="margin-top: 4px;">
                        <label class="am-radio-inline">
                            <input name="type" type="radio" value="view"  @if(!isset($data['id']) || (isset($data['type']) && $data['type'] == 'view')) checked="checked" @endif> 跳转Url
                        </label>
                        <label class="am-radio-inline">
                            <input name="type" type="radio" value="click"  @if((isset($data['type']) && $data['type'] == 'click')) checked="checked" @endif> 点击事件
                        </label>

                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">关键字：</div>
                    <div class="you">
                        <input style="width:200px" class="am-input-sm" name="key" type="text" value="{{isset($data['key']) ? $data['key'] : ''}}" placeholder="输入关键字" />
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">链接url：</div>
                    <div class="you">
                        <input  style="width:500px" class="am-input-sm" name="url" type="text" value="{{isset($data['url']) ? $data['url'] : ''}}" placeholder="输入链接url,必须是以 http:// 打头" />
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">排序：</div>
                    <div class="you">
                        <input style="width:100px"  class="am-input-sm" name="sort" type="text" value="{{isset($data['sort']) ? $data['sort'] : 0}}" placeholder="输入排序" />
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">是否开启：</div>
                    <div class="you" style="margin-top: 4px;">
                        <label class="am-radio-inline">
                            <input type="radio"  value="1" @if(!isset($data['id']) || (isset($data['status']) && ($data['status'] == 1))) checked="checked" @endif name="status"> 是
                        </label>
                        <label class="am-radio-inline">
                            <input type="radio"  value="0" @if(isset($data['status']) && ($data['status'] == 0)) checked="checked" @endif name="status"> 否
                        </label>

                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="you">
                        <p>
                            <input type="hidden" name="id" value="{{isset($data['id'])}}">
                            <button type="submit" class="am-btn am-btn-success am-radius">提交</button>
                        </p>
                    </div>
                </div>
            </form>
        </div>

        <div class="foods">
            <ul>
                版权所有@2015
            </ul>
            <dl>
                <a href="" title="返回头部" class="am-icon-btn am-icon-arrow-up"></a>
            </dl>
        </div>
    </div>
@section('script')
<script>
    var message = "{{Session::get('message')}}";
    $(window).ready(function () {
        if (message) {
            layer.msg(message, {
                time: 3000 //2秒关闭（如果不配置，默认是3秒）
            });
        }
    });
    function deleteMenu(url,id) {
        $.get(url, function (res) {
            var icon = 5;
            if (res.status) {
                $("#tr_"+id).hide();
                icon = 6;
            }
            layer.msg(res.msg,{icon:icon});
        });
    }

    function makeMenu() {
        var url = '{{urlAdmin('wechatMenus','getMakeMenu')}}';
        $.get(url, function (res) {
            var icon = 5;
            if (res.errcode == 0) {
                icon = 6;
            }
            layer.msg(res.errmsg,{icon:icon});
        });
    }
</script>
@endsection
@endsection